#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;


class BunnyPuzzle {
public:
	int theCount(vector <int> bunnies) {
		bunnies.push_back(10000000);
        bunnies.push_back(-10000000);
        sort(bunnies.begin(),bunnies.end());
        int sz=bunnies.size();
        int c,cnt=0;
        for(int i=1;i<sz-2;i++){
            c=2*bunnies[i+1]-bunnies[i];
            if(c<bunnies[i+2])
                cnt++;
        }
        for(int i=sz-2;i>=2;i--){
            c=2*bunnies[i-1]-bunnies[i];
            if(c>bunnies[i-2])
                cnt++;
        }
        return cnt;
	}
};


// BEGIN KAWIGIEDIT TESTING
// Generated by KawigiEdit 2.1.8 (beta) modified by pivanof
#include <iostream>
#include <string>
#include <vector>
using namespace std;
bool KawigiEdit_RunTest(int testNum, vector <int> p0, bool hasAnswer, int p1) {
	cout << "Test " << testNum << ": [" << "{";
	for (int i = 0; int(p0.size()) > i; ++i) {
		if (i > 0) {
			cout << ",";
		}
		cout << p0[i];
	}
	cout << "}";
	cout << "]" << endl;
	BunnyPuzzle *obj;
	int answer;
	obj = new BunnyPuzzle();
	clock_t startTime = clock();
	answer = obj->theCount(p0);
	clock_t endTime = clock();
	delete obj;
	bool res;
	res = true;
	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
	if (hasAnswer) {
		cout << "Desired answer:" << endl;
		cout << "\t" << p1 << endl;
	}
	cout << "Your answer:" << endl;
	cout << "\t" << answer << endl;
	if (hasAnswer) {
		res = answer == p1;
	}
	if (!res) {
		cout << "DOESN'T MATCH!!!!" << endl;
	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
		cout << "FAIL the timeout" << endl;
		res = false;
	} else if (hasAnswer) {
		cout << "Match :-)" << endl;
	} else {
		cout << "OK, but is it right?" << endl;
	}
	cout << "" << endl;
	return res;
}
int main() {
	bool all_right;
	all_right = true;
	
	vector <int> p0;
	int p1;
	
	{
	// ----- test 0 -----
	int t0[] = {5,8};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	p1 = 2;
	all_right = KawigiEdit_RunTest(0, p0, true, p1) && all_right;
	// ------------------
	}
	
	{
	// ----- test 1 -----
	int t0[] = {-1,0,1};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	p1 = 2;
	all_right = KawigiEdit_RunTest(1, p0, true, p1) && all_right;
	// ------------------
	}
	
	{
	// ----- test 2 -----
	int t0[] = {0,1,3};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	p1 = 3;
	all_right = KawigiEdit_RunTest(2, p0, true, p1) && all_right;
	// ------------------
	}
	
	{
	// ----- test 3 -----
	int t0[] = {-677,-45,-2,3,8,29,384,867};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	p1 = 7;
	all_right = KawigiEdit_RunTest(3, p0, true, p1) && all_right;
	// ------------------
	}
	
	{
	// ----- test 4 -----
	int t0[] = {0,1,2,3,4,5,6,7,8,9};
			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
	p1 = 2;
	all_right = KawigiEdit_RunTest(4, p0, true, p1) && all_right;
	// ------------------
	}
	
	if (all_right) {
		cout << "You're a stud (at least on the example cases)!" << endl;
	} else {
		cout << "Some of the test cases had errors." << endl;
	}
	return 0;
}
// PROBLEM STATEMENT
// NOTE: This problem statement contains images that may not display properly if viewed outside of the applet.
// 
// 
// Taro and Hanako are playing Bunny Puzzle. There are several bunnies standing on a line. You are given a vector <int> bunnies, where each element is the initial position of a single bunny.
// 
// 
// They must perform the following routine exactly once:
// 
// Choose two different bunnies A and B, located at points a and b, respectively.
// A jumps over B and lands at point 2*b-a.
// 
// 
// 
// 
// 
// 
// 
// The jump is not allowed if another bunny is already at point 2*b-a.
// 
// 
// 
// 
// 
// The jump is also not allowed if A jumps over more than one bunny.
// 
// 
// 
// 
// 
// 
// 
// 
// Return the number of different ways in which Taro and Hanako can choose the pair of bunnies A and B. "A jumps over B" and "B jumps over A" are considered to be different.
// 
// 
// 
// DEFINITION
// Class:BunnyPuzzle
// Method:theCount
// Parameters:vector <int>
// Returns:int
// Method signature:int theCount(vector <int> bunnies)
// 
// 
// CONSTRAINTS
// -bunnies will contain between 2 and 50 elements, inclusive.
// -Each element of bunnies will be between -10^6 and 10^6, inclusive.
// -bunnies will be sorted in strictly ascending order.
// 
// 
// EXAMPLES
// 
// 0)
// {5, 8}
// 
// Returns: 2
// 
// There are two possible moves:
// 
// A bunny jumps from 5 to 11
// A bunny jumps from 8 to 2
// 
// 
// 1)
// {-1, 0, 1}
// 
// Returns: 2
// 
// There are two possible moves:
// 
// A bunny jumps from 0 to -2
// A bunny jumps from 0 to 2
// 
// 
// 2)
// {0, 1, 3}
// 
// Returns: 3
// 
// There are three possible moves:
// 
// A bunny jumps from 0 to 2
// A bunny jumps from 1 to -1
// A bunny jumps from 1 to 5
// 
// 
// 3)
// {-677, -45, -2, 3, 8, 29, 384, 867}
// 
// Returns: 7
// 
// 
// 
// 4)
// {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
// 
// Returns: 2
// 
// 
// 
// END KAWIGIEDIT TESTING
//Powered by KawigiEdit 2.1.8 (beta) modified by pivanof!
